package edu.gdkm.dao;

import edu.gdkm.pojo.CompanyInfo;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * 企业信息数据访问接口
 */
public interface CompanyInfoDao {
    
    /**
     * 插入企业信息
     */
    @Insert("INSERT INTO company_info(user_id, company_name, industry, scale, nature, introduction, address, website, contact_person, create_time, update_time) VALUES(#{userId}, #{companyName}, #{industry}, #{scale}, #{nature}, #{introduction}, #{address}, #{website}, #{contactPerson}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(CompanyInfo companyInfo);
    
    /**
     * 根据ID删除企业信息
     */
    @Delete("DELETE FROM company_info WHERE id = #{id}")
    int deleteById(Long id);
    
    /**
     * 更新企业信息
     */
    @Update("UPDATE company_info SET user_id = #{userId}, company_name = #{companyName}, industry = #{industry}, scale = #{scale}, nature = #{nature}, introduction = #{introduction}, address = #{address}, website = #{website}, contact_person = #{contactPerson}, update_time = #{updateTime} WHERE id = #{id}")
    int update(CompanyInfo companyInfo);
    
    /**
     * 根据ID查询企业信息
     */
    @Select("SELECT id, user_id, company_name, industry, scale, nature, introduction, address, website, contact_person, create_time, update_time FROM company_info WHERE id = #{id}")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "userId", column = "user_id"),
        @Result(property = "companyName", column = "company_name"),
        @Result(property = "industry", column = "industry"),
        @Result(property = "scale", column = "scale"),
        @Result(property = "nature", column = "nature"),
        @Result(property = "introduction", column = "introduction"),
        @Result(property = "address", column = "address"),
        @Result(property = "website", column = "website"),
        @Result(property = "contactPerson", column = "contact_person"),
        @Result(property = "createTime", column = "create_time"),
        @Result(property = "updateTime", column = "update_time")
    })
    CompanyInfo selectById(Long id);
    
    /**
     * 查询所有企业信息
     */
    @Select("SELECT id, user_id, company_name, industry, scale, nature, introduction, address, website, contact_person, create_time, update_time FROM company_info")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "userId", column = "user_id"),
        @Result(property = "companyName", column = "company_name"),
        @Result(property = "industry", column = "industry"),
        @Result(property = "scale", column = "scale"),
        @Result(property = "nature", column = "nature"),
        @Result(property = "introduction", column = "introduction"),
        @Result(property = "address", column = "address"),
        @Result(property = "website", column = "website"),
        @Result(property = "contactPerson", column = "contact_person"),
        @Result(property = "createTime", column = "create_time"),
        @Result(property = "updateTime", column = "update_time")
    })
    List<CompanyInfo> selectAll();
    
    /**
     * 根据用户ID查询企业信息
     */
    @Select("SELECT id, user_id, company_name, industry, scale, nature, introduction, address, website, contact_person, create_time, update_time FROM company_info WHERE user_id = #{userId}")
    @Results({
        @Result(property = "id", column = "id"),
        @Result(property = "userId", column = "user_id"),
        @Result(property = "companyName", column = "company_name"),
        @Result(property = "industry", column = "industry"),
        @Result(property = "scale", column = "scale"),
        @Result(property = "nature", column = "nature"),
        @Result(property = "introduction", column = "introduction"),
        @Result(property = "address", column = "address"),
        @Result(property = "website", column = "website"),
        @Result(property = "contactPerson", column = "contact_person"),
        @Result(property = "createTime", column = "create_time"),
        @Result(property = "updateTime", column = "update_time")
    })
    CompanyInfo selectByUserId(Long userId);
}
